library("tidyverse")
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
library("ggplot2")
library("ggrepel")
library("ggcorrplot")
library("DT")
library("dplyr")
cases <- read_csv("COVID-19_cases_plus_census.csv")
Rows: 3142 Columns: 259── Column specification ───────────────────────────────────────────────────────────────────
Delimiter: ","
chr (5): county_fips_code, county_name, state, state_fips_code, geo_id
dbl (243): confirmed_cases, deaths, nonfamily_households, family_households, median_ye...
lgl (10): pop_5_years_over, speak_only_english_at_home, speak_spanish_at_home, speak_...
date (1): date
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
cases
cases <- cases %>% mutate_if(is.character, factor)
dim(cases)
[1] 3142 259
cases_high <- cases %>% filter(confirmed_cases > 300000)
dim(cases_high)
[1] 4 259
summary(cases_high[,1:10])
county_fips_code county_name state state_fips_code date confirmed_cases
04013 :1 Cook County :1 AZ :1 04 :1 Min. :2021-01-19 Min. : 347965
06037 :1 Los Angeles County:1 CA :1 06 :1 1st Qu.:2021-01-19 1st Qu.: 406374
12086 :1 Maricopa County :1 FL :1 12 :1 Median :2021-01-19 Median : 430866
17031 :1 Miami-Dade County :1 IL :1 17 :1 Mean :2021-01-19 Mean : 553078
01001 :0 Abbeville County :0 AK :0 01 :0 3rd Qu.:2021-01-19 3rd Qu.: 577570
01003 :0 Acadia Parish :0 AL :0 02 :0 Max. :2021-01-19 Max. :1002614
(Other):0 (Other) :0 (Other):0 (Other):0
deaths geo_id nonfamily_households family_households
Min. : 4622 04013 :1 Min. : 272813 Min. : 585476
1st Qu.: 5988 06037 :1 1st Qu.: 453163 1st Qu.: 878560
Median : 7494 12086 :1 Median : 643445 Median :1079603
Mean : 8386 17031 :1 Mean : 662745 Mean :1237151
3rd Qu.: 9892 01001 :0 3rd Qu.: 853027 3rd Qu.:1438194
Max. :13936 01003 :0 Max. :1091276 Max. :2203922
(Other):0
ggplot(cases_high, mapping = aes(confirmed_cases)) + geom_histogram(bins = 10)